package org.example.controller;


import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.example.exception.CusAuthenticationException;
import org.example.result.R;
import org.example.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;


    @RequestMapping("/login")
    public R login(@RequestParam("username") String username, @RequestParam("password") String password){
        //TODO: implement login logic here
        return userService.login(username, password);
    }

    @RequestMapping("/logout")
    public R logout(HttpServletRequest request) throws CusAuthenticationException {
        return userService.logout(request);
    }
}
